package com.pig4cloud.pig.admin.provider;

import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pig.admin.api.vo.WebIndexQuery;
import org.apache.ibatis.annotations.Param;

import java.util.Date;

/**
 * @Description: WebIndexProvider
 * @author: wlf
 * @date: 2021年07月18日 22:04
 */
public class WebIndexProvider {


//	public String queryList(@Param("page") Page page,@Param("webIndexQuery") WebIndexQuery webIndexQuery){
//		StringBuffer sql = new StringBuffer();
//		int current = (int) page.getCurrent();
//		int size = (int) page.getSize();
//		sql.append(" SELECT * FROM web_index wi ");
//		sql.append(" WHERE 1=1 ");
//		sql.append(this.setTabCondition(webIndexQuery));
//		sql.append(" ORDER BY wi.create_date DESC  ");
//		sql.append(" LIMIT ").append((current-1)*size).append(",").append(size);
//		return sql.toString();
//	}

	private String setTabCondition(WebIndexQuery webIndexQuery) {
		StringBuffer sql = new StringBuffer();
		if (StringUtils.isNotBlank(webIndexQuery.getWebName())){
			sql.append(" AND wi.web_name LIKE CONCAT('%' #{webIndexQuery.webName} '%') ");
		}else if (StringUtils.isNotBlank(webIndexQuery.getWebUrl())){
			sql.append(" AND wi.web_name LIKE CONCAT('%' #{webIndexQuery.webUrl} '%') ");
		}else if (StringUtils.isNotBlank(webIndexQuery.getCreateName())){
			sql.append(" AND wi.web_name LIKE CONCAT('%' #{webIndexQuery.createName} '%') ");
		}
		return sql.toString();
	}


}
